package com.acme.javaschool.intense.sems.sem2concurrency.pool.data;

public class PoolableObject<T> {
    private boolean isClosed;
    private final T data;

    public PoolableObject(T data) {
        isClosed = true;
        this.data = data;
    }

    public boolean isClosed() {
        return isClosed;
    }

    public T getData() {
        if (!isClosed) {
            return data;
        } else {
            return null;
        }
    }

    public void open() {
        isClosed = false;
    }

    public void close() {
        isClosed = true;
    }
}
